﻿using System.Web;
using System.Reflection;
using System.IO;

namespace Db7.HttpHandlers
{
    public class ResourceLib : IHttpHandler
    {
        public bool IsReusable
        {
            get { return false; }  //TODO:  true?
        }

        public void ProcessRequest(HttpContext context)
        {
            var resourcePath = context.Request["Db7_r"];
            if (resourcePath == null) return;
            var assembly = Assembly.GetExecutingAssembly();
            //imageStream = _assembly.GetManifestResourceStream("MyNamespace.MyImage.bmp");
            var resource = assembly.GetManifestResourceStream(resourcePath);
            var textStreamReader = new StreamReader(resource);
            context.Response.Write(textStreamReader.ReadToEnd());
            textStreamReader.Close();
        }
    }
}
